package dto

import (
	"time"
	"wxpay/internal/model"
	"wxpay/pkg/util"
)

type TransferDetailDTO struct {
	ID int64
	// 明细单号
	OutDetailNo string
	// 上游业务明细单号
	BizDetailNo string
	// 转账金额
	Amount int64
	// 转账备注
	Remark string
	// 用户openID
	OpenID string
	// 用户姓名
	UserName string
	// 用户身份证号
	UserIDCard string
	// 转账状态
	Status string
	// 失败原因
	FailReason string
	// 转账发起时间
	InitiateTime *time.Time
	// 商户ID绑定的AppID
	AppID string
	// 批次号
	OutBatchNo string
	// 商户ID - 出资方
	MchID string
}

// dto to model
func AdaptTransferDetail(info *TransferDetailDTO) (r *model.TransferDetail) {
	r = &model.TransferDetail{
		BizDetailNo: info.BizDetailNo,
		Amount:      info.Amount,
		Remark:      info.Remark,
		OpenID:      info.OpenID,
		UserName:    info.UserName,
		UserIDCard:  util.AdaptNullString(info.UserIDCard),
		AppID:       info.AppID,
		MchID:       info.MchID,
	}
	return
}

// model to dto
func ConvertTransferDetail(info *model.TransferDetail) (r *TransferDetailDTO) {
	r = &TransferDetailDTO{
		ID:           info.ID,
		OutDetailNo:  info.OutDetailNo,
		BizDetailNo:  info.BizDetailNo,
		Amount:       info.Amount,
		Remark:       info.Remark,
		OpenID:       info.OpenID,
		UserName:     info.UserName,
		UserIDCard:   util.ConvertNullString(info.UserIDCard),
		Status:       info.Status,
		FailReason:   util.ConvertNullString(info.FailReason),
		InitiateTime: info.InitiateTime,
		AppID:        info.AppID,
		OutBatchNo:   util.ConvertNullString(info.OutBatchNo),
		MchID:        info.MchID,
	}
	return
}
